import QtQuick 2.5
import QtQuick.Layouts 1.1
import QtQuick.Window 2.2
import QtQuick.Controls 1.4
import QtQuick.Controls.Styles 1.2
import com.ColumnListModel 1.0


//import "./Query"

//表头设置
Window {
    id: eo_askDialog
    modality: Qt.NonModal
    width: 670
    height: 420
    visible: false
    //    maximumWidth: 500;
    //    maximumHeight: 400;
    //    minimumHeight:350;
    //    minimumWidth:340;
    title: qsTr("表头设置--") + curlistName
    color: "lightgray"

    signal updateUIColumn(string sList)

    property string curlistName

    //    property Item refList
    onClosing: {
        console.log(qsTr('ColumnSet Window destroy'))
    }

    //    Component{   //高亮条
    //        id:highlight;
    //        Rectangle{
    //            color:"lightsteelblue";radius:5;
    //        }
    //    }
    Component {
        id: rowDel
        Rectangle {
            RowLayout {
                anchors.fill: parent
                TextField {
                    Layout.preferredWidth: 90
                }
            }
        }
    }

    ColumnListView {
        id: colList
        anchors.left: parent.left
        anchors.leftMargin: 10
        anchors.top: parent.top
        anchors.topMargin: 10
        anchors.bottom: parent.bottom
        anchors.right: parent.right
        anchors.rightMargin: 100
        anchors.bottomMargin: 15
        //        width: parent.width - 150;
    }

    ColumnLayout {
        spacing: 20
        //                anchors.left:panelList.right;
        anchors.leftMargin: 24
        anchors.top: parent.top
        anchors.topMargin: 25
        anchors.bottom: parent.bottom
        anchors.right: parent.right
        anchors.rightMargin: 15

        Button {
            anchors.topMargin: 40
            //                    anchors.leftMargin: 30
            text: qsTr("上移")
            onClicked: {
                colList.moveUp()
            }
        }

        Button {
            text: qsTr("下移")
            onClicked: {
                colList.moveDown()
            }
        }

        Button {
            text: qsTr("增加")
            onClicked: {
                colList.insertRow()
            }
        }

        Button {
            text: qsTr("保存")
            onClicked: {
                colCfg.saveColumnCfg(curlistName, colList.colModel)
                //                refList.updateColumn(curlistName)
                updateUIColumn(curlistName)
                eo_askDialog.close()
            }
        }
    }

    //    }
    function loadColumnCfg(listName) {
        console.log(qsTr('loadColumnCfg: "' + listName + '"'))
        curlistName = listName
        colList.colModel = colCfg.getColumnModel(listName)
    }
}
